<#include "/generation-templates/directive/contains.ftl"/>
package ${package};

import lombok.Data;
<@contains tableInfo = table rules = "img">
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.ilxqx.framework.system.entity.anno.FileKey;
</@contains>
import com.ilxqx.framework.system.entity.anno.Excel;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

<#list table.getFields() as field>
<#if field.getRules().match("enum")>
import ${field.getType().getName()};
</#if>
</#list>

/**
 * ${table.getComment()}实体类
 * @author venus
 */
@Entity(name = "${table.getName()}")
@Data
@DynamicInsert
@DynamicUpdate
public class ${table.getCamelName()} implements Serializable {

    private static final long serialVersionUID = 1L;

    <#list table.getFields() as field>
    <#if field.isPrimaryKey()>
    /**
     * ${field.getComment()}
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private ${field.getType().getSimpleName()} ${field.getLowerCamelName()};

    <#else>
    /**
     * ${field.getComment()}
     */
    <#if field.getRules().match("excel")>
    @Excel(value = "${field.getComment()}"<#if field.getRules().getRule("excel").getParam("method")?has_content>, method = "${field.getRules().getRule("excel").getParam("method")}"</#if>)
    </#if>
    <#if field.getRules().match("img")>
    @FileKey
    @JsonSerialize(using = FileKeyFieldSerializer.class)
    </#if>
    private ${field.getType().getSimpleName()} ${field.getLowerCamelName()};

    </#if>
    </#list>
}